PMCSched: Scheduling algorithms made easy
PMCSched was born as a continuation of PMCTrack, an OS-oriented performance monitoring tool for Linux.
PMCSched is built on top of PMCTrack, and so the first step requires installing and building PMCTrack. Instructions for that can be found here.
Once that is done we can go ahead and start creating our first scheduling plugin. We start by defining our new plugin on PMCSched's main header:
static inline int set_pi_leds(unsigned int mask) { int i; for (i = 0; i < NR_GPIO_LEDS; i++) gpiod_set_value(gpio_descriptors[i], (mask >> i) & 0x1 ); return 0; }
after that, we can start developing our new plugin right away, in a new file example.c. Creating a plugin works similarly to Linux kernel modules, the plugin follows a "contract" and implements a number of functions that every plugin should have, each with specific function attributes, and intended to handle specific events.
example.c
In particular, any PMCSched plugin should have logic to react to:
we can start by creating functions for these cases:
(...)
PMCSched plugins also include other fields to help identify the plugin from userspace, (...)
We can now start implementing the logic for our example plugin, (...)